package cn.qiyu5522.controller;

import cn.qiyu5522.constant.SystemConsKeys;
import cn.qiyu5522.domain.entity.ResponseResult;
import cn.qiyu5522.service.UploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Api(tags = "文件上传相关接口")
@RestController
public class UploadController {
    @Autowired
    private UploadService uploadService;

    @ApiOperation(value = "头像上传",notes = "用户修改个人信息时上传头像")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "img",value = "存储上传图片信息"),
    })
    @PostMapping("/avatar/upload")
    public ResponseResult avatarUploadImg(MultipartFile img){
        return uploadService.uploadImg(img, SystemConsKeys.AVATAR_UPLOAD);
    }


    @PostMapping("/upload")
    public ResponseResult articleImgUploadImg(MultipartFile img){
        return uploadService.uploadImg(img, SystemConsKeys.ARTICLE_IMAGE_UPLOAD);
    }
}